package com.compname.pro1.net;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.Socket;

public class Customer implements Runnable {
	private Socket sk;
	
	public Customer(Socket sk) {
		super();
		this.sk = sk;
	}

	@Override
	public void run() {
		BufferedReader reader = null;
		OutputStream out = null;
		try {
			out = sk.getOutputStream();
			reader = new BufferedReader(new InputStreamReader(sk.getInputStream()));
			out.write("please input your name:\n".getBytes());
			String line = reader.readLine();
			System.out.println(line);
			out.write(("Hello " + line + "\n").getBytes());
		} catch (IOException e) {

			e.printStackTrace();
		}

		finally {
			try {
				out.close();
				reader.close();
				sk.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

	}
}
